# Contributor: Artyom Smirnov <smirnoffjr@gmail.com>
pkgname=repo-clean-hg
pkgver=83
pkgrel=1
pkgdesc="Clean utility for Pacman repository"
arch=('i686' 'x86_64')
url="http://code.google.com/p/repo-clean/"
license=('GPL')
depends=('pacman' 'boost')
makedepends=('cmake' 'gcc' 'mercurial')
provides=(repo-clean)
conflicts=(repo-clean)
source=()
md5sums=()

_hgroot=http://repo-clean.googlecode.com/hg/
_hgrepo=repo-clean

build() {
    cd "${srcdir}"

    if [ -d ${_hgrepo}/.hg ]; then
        cd ${_hgrepo}
        hg pull
        hg update -C --rev ${pkgver}
    else
        hg clone ${_hgroot} ${_hgrepo} --rev ${pkgver} || return 1
    fi

    msg "Mercurial checkout done or server timeout"
    msg "Starting building..."

    rm -rf "${srcdir}/${_hgrepo}-build"
    cp -r "${srcdir}/${_hgrepo}" "${srcdir}/${_hgrepo}-build"
    cd "${srcdir}/${_hgrepo}"
    
    mkdir build
    cd build
    cmake -DCMAKE_INSTALL_PREFIX=/usr ..
    make
    make DESTDIR="${pkgdir}" install
}
